package com.yunjian.admin.config.log;

import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnWebApplication
public class ChangeLogConfiguration {

	@Bean
	@ConditionalOnMissingBean
	public ChangeLogEndpoint changeLogEndpoint() {
		return new ChangeLogEndpoint();
	}

	@Bean
	@ConditionalOnBean(ChangeLogEndpoint.class)
	@ConditionalOnEnabledEndpoint(value = "changeLog")
	public ChangeLogMvcEndpoint changeLogMvcEndpoint(ChangeLogEndpoint delegate) {
		return new ChangeLogMvcEndpoint(delegate);
	}
}
